package com.linkwedo.saas.project;

import java.sql.Timestamp;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.linkwedo.saas.domain.Project;
import com.linkwedo.saas.domain.Target;
import com.linkwedo.saas.domain.Task;
import com.linkwedo.saas.util.DateUtil;
import com.opensymphony.xwork2.ActionSupport;


public class AddTargetAction extends ActionSupport implements ServletRequestAware{
	private TargetService targetService;

	private Integer id;
	private String name;
	private Timestamp createTime;
	private Date dueDate;
	private String description;
	private String tag;
	private String note;
	private String projectId;
	private javax.servlet.http.HttpServletRequest request;
	public void setServletRequest(HttpServletRequest request) {
		// TODO Auto-generated method stub
		this.request=request;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public Timestamp getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	public Date getDueDate() {
		return dueDate;
	}

	public void setDueDate(Date dueDate) {
		this.dueDate = dueDate;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	
	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}


	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}
	private List<Target> list;
	public List<Target> getList() {
		return list;
	}

	public void setList(List<Target> list) {
		this.list = list;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}
	private static final long serialVersionUID = 8190003683775267239L;
	public String execute() throws Exception {
		name=request.getParameter("name");
		description=request.getParameter("description");
		createTime=DateUtil.str2Timestamp(request.getParameter("createTimeStr"));
		dueDate=DateUtil.str2Date(request.getParameter("dueDateStr"),"yyyy-MM-dd HH:mm:ss");
		tag=request.getParameter("tag");
		note=request.getParameter("note");
		projectId = request.getParameter("projectId");
		Target pro=new Target();
		pro.setName(name);
		pro.setDescription(description);
		pro.setCreateTime(createTime);
		pro.setDueDate(dueDate);
		pro.setNote(note);
		pro.setProjectId(Integer.parseInt(projectId));
		getTargetService().save(pro);
		list=getTargetService().findAll();
		return "ok";
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public TargetService getTargetService() {
		return targetService;
	}

	public void setTargetService(TargetService targetService) {
		this.targetService = targetService;
	}

	public String getProjectId() {
		return projectId;
	}

	public void setProjectId(String projectId) {
		this.projectId = projectId;
	}
	
	}
